package com.zr.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.interceptor.SessionAware;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import com.opensymphony.xwork2.ActionContext;
import com.zr.model.Corder;
import com.zr.model.Cuser;
import com.zr.service.OnblurService;
@Controller
public class OnblurAction implements ServletResponseAware,SessionAware,ServletRequestAware{
	private HttpServletResponse resp;
	private Map<String, Object> session;
	private HttpServletRequest request;
	private int oid;
	
	public int getOid() {
		return oid;
	}
	public void setOid(int oid) {
		this.oid = oid;
	}
	@Override
	public void setServletRequest(HttpServletRequest arg0) {
		// TODO Auto-generated method stub
		this.request=arg0;
	}
	@Override
	public void setServletResponse(HttpServletResponse arg0) {
		// TODO Auto-generated method stub
		this.resp=arg0;
	}
	@Override
	public void setSession(Map<String, Object> arg0) {
		// TODO Auto-generated method stub
		this.session=arg0;
	}
	@Resource
	private OnblurService onblseim;
	
	public void onblur(){
		resp.setCharacterEncoding("utf8");
		try {
			PrintWriter pw=resp.getWriter();
			Corder co=onblseim.getOrderByOid(oid);
			if(co!=null){
				
				
				ActionContext.getContext().put("goodsname", co.getGoodsname());
				 request.setAttribute("goodsname", co.getGoodsname());
				  request.setAttribute("startp", co.getStartp());
				 
				  request.setAttribute("endp", co.getEndp());
//					session.put("goodsname", co.getGoodsname());
//					session.put("startp", co.getStartp());
//					session.put("endp", co.getEndp());
//					session.put("goodsname", co.getGoodsname());
				  pw.write("1");
				
			}else{
				 pw.write("0");
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	

}
